import requests from "./ajax";
import mockRequests from "./mockAjax";

//三级联动接口
// 路径：api/product/getBaseCategoryList get 无参数
// export const reqCategoryList = () => {
//     //发送axios请求返回结果为promise
//     return requests({
//         url: '/product/getBaseCategoryList',
//         method: 'get'
//     })
// }
//三级联动简写形式
export const reqCategoryList = () => requests({ url: '/product/getBaseCategoryList', method: 'get' })

//banner
export const reqBannerList = () => mockRequests.get('/banner')

//floor
export const reqFloorList = () => mockRequests.get('/floor')

//search
export const reqSearchInfo = (params) => requests({ url: '/list', method: 'post', data: params })

// 详情页
export const reqGoodsInfo = skuid => requests({ url: `/item/${skuid}`, method: 'get' })

// 添加到购物车
export const reqAddOrUpdateShopCart = (skuId, skuNum) => requests({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: 'post' })

// 购物车
export const reqCartList = () => requests({ url: "/cart/cartList", method: 'get' })

// 删除购物车商品
export const reqDeleteCartById = (skuId) => requests({ url: `/cart/deleteCart/${skuId}`, method: 'delete' })

// 修改商品选中状态
export const reqUpdateCheckedById = (skuId, isChecked) => requests({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' })

// 获取验证码
export const reqGetCode = (phone) => requests({ url: `/user/passport/sendCode/${phone}`, method: 'get' })

// 注册
export const reqUserRegister = (params) => requests({ url: "/user/passport/register", data: params, method: 'post' })

// 登陆
export const reqUserLogin = (data) => requests({ url: "/user/passport/login", data, method: 'post' })

// 获取用户登陆信息
export const reqUserInfo = () => requests({ url: "/user/passport/auth/getUserInfo", method: 'get' })

// 退出登陆
export const reqUserLogout = () => requests({ url: "/user/passport/logout", method: 'get' })

// 获取用户地址信息
export const reqAddressInfo = () => requests({ url: "/user/userAddress/auth/findUserAddressList", method: 'get' })

// 获取订单的交易信息
export const reqTradeInfo = () => requests({ url: "/order/auth/trade", method: 'get' })

// 获取订单的支付信息
export const reqSubmitOrderInfo = (tradeNo, data) => requests({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, data, method: 'post' })

// 获取支付信息
export const reqPayInfo = (orderId) => requests({ url: `/payment/weixin/createNative/${orderId}`, method: 'get' })

// 获取个人中心
export const reqMyOrderInfo = (page, limit) => requests({ url: `/order/auth/${page}/${limit}`, method: 'get' })
